<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<style>
			
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">个人信息</h1>
		</header>
		<div class="mui-content">
			<ul class="mui-table-view mui-table-view-chevron">
				<li class="mui-table-view-cell">
					<a href="javascrpt:void(0)">
						<span class="mui-icon mui-icon-person"></span> 登录账号
						<span class="mui-pull-right" id="MemberAccount"></span>
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a href="javascrpt:void(0)">
						<span class="mui-icon mui-icon-phone"></span> 手机号码
						<span class="mui-pull-right" id="MobileNo"></span>
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a href="javascrpt:void(0)">
						<span class="mui-icon mui-icon-email"></span> 邮箱
						<span class="mui-pull-right" id="Email"></span>
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a href="javascrpt:void(0)" class="mui-navigate-right" id="btnSetNickname">
						<span class="mui-icon mui-icon-flag"></span> 昵称
						<span class="mui-pull-right" id="Nickname"></span>
					</a>
				</li>
			</ul>			
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/DataBind.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/resources.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
			
			var userData, user, $Nickname;
			var $wvAccount;
			
			function init(){
				userData = app.getUser();
				user = userData.User;
				$Nickname = document.getElementById("Nickname");
				
				console.log(JSON.stringify(app.getUser()));			
	
				document.getElementById("MemberAccount").innerText = user.MemberAccount;
				document.getElementById("MobileNo").innerText = user.MobileNo;
				document.getElementById("Email").innerText = user.Email;
				$Nickname.innerText = user.Nickname;				
			};
			
			init();
			
			document.getElementById("btnSetNickname").addEventListener('tap',function(){
				mui.prompt('给自己取个好听的昵称吧','昵称','设置昵称',['确定','取消'],function(e){
					console.log(JSON.stringify(e));
					if(e.index == 0){
						plus.nativeUI.showWaiting();
						app.post("SetNickname", {MemberAccount:user.MemberAccount, Nickname:e.value}, function(data){
							userData.User.Nickname = e.value;
							app.setUser(userData);
							$Nickname.innerText = user.Nickname;
							$wvAccount.evalJS("setNickname('"+ user.Nickname +"')");
							mui.toast("设置昵称成功")
						});
					}
				},'div');
				document.querySelector('.mui-popup-input input').value = user.Nickname; 
			});

			mui.plusReady(function() {
				$wvAccount = plus.webview.getWebviewById("account.html");
			});
			
		</script>
	</body>

</html>